package com.chinatelecom.check.service.impl;

import java.util.List;
import java.util.stream.Collectors;

import com.chinatelecom.check.dao.CheckTaskOrgMapper;
import com.chinatelecom.check.entity.CheckTaskOrg;
import com.chinatelecom.check.model.CheckTaskOrgModel;
import com.chinatelecom.check.service.CheckTaskOrgService;
import com.chinatelecom.framework.generic.GenericServiceImpl;
import com.chinatelecom.framework.model.PageData;
import com.chinatelecom.framework.model.PageParam;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.hutool.core.bean.BeanUtil;


/**
 * CheckTaskOrg服务实现
 */
@Service
@Transactional
public class CheckTaskOrgServiceImpl extends GenericServiceImpl<CheckTaskOrg> implements CheckTaskOrgService {
	
	@Autowired
	private CheckTaskOrgMapper mapper;
	
	@Override
	public CheckTaskOrgModel getDetail(Integer id) {
		CheckTaskOrgModel model = new CheckTaskOrgModel();
		CheckTaskOrg record = mapper.selectById(id);
		BeanUtil.copyProperties(record, model);
		return model;
	}
	
	@Override
	public PageData<CheckTaskOrgModel> page(PageParam param) {
		PageData<CheckTaskOrg> data = super.getPageData(param);

		List<CheckTaskOrgModel> list = data.getList().stream().map(a -> {
			CheckTaskOrgModel dto = new CheckTaskOrgModel();
			BeanUtils.copyProperties(a, dto);
			return dto;
		}).collect(Collectors.toList());

		PageData<CheckTaskOrgModel> result = new PageData<CheckTaskOrgModel>();
		BeanUtils.copyProperties(data, result);
		result.setList(list);
		return result;
	}


}
